package com.fbty.mt.test;

import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.LinkedBlockingDeque;

import com.fbty.mt.domain.IpInfo;
import com.fbty.mt.utils.BatchSpeed;
import com.fbty.mt.utils.IPSpeed;


public class Ping {
	public static final String BYTES = "bytes";
	public static final String TIME = "time";

	/**
	 * Description: <br>
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
	  /*final Deque<String> queue = new LinkedBlockingDeque<String>();
	  queue.add("192.168.16.113");
	  queue.add("192.168.16.112");
	  queue.add("192.168.16.115");
	  queue.add("72.64.146.135");
	  queue.add("192.168.16.111");
	  queue.add("192.168.16.119");
	  queue.add("192.168.16.117");
	  queue.add("89.251.103.130");
	  queue.add("www.taobao.com");
	  queue.add("www.360buy.com");
	  queue.add("www.hao123.com");
	  queue.add("220.181.112.143");
	  queue.add("www.sina.com.cn");
	  queue.add("www.google.com.hk");
	  long time1=System.currentTimeMillis();
	  System.out.println(time1+"--------------");
	  over:
	  while(true){
		for(int i=0;i<5;i++){
			if(queue.size()==0)
				break over;
			new Thread(){
				public void run(){
					if(queue.size()>0){
						String str =queue.removeFirst();
						String d = IPSpeed.getSpeed(str);
						System.out.println(d+"--"+str+"---"+System.currentTimeMillis());
					}
				}
			}.start();
		}
	  }
	  long time2=System.currentTimeMillis();
	  System.out.println((time2-time1)+"--------------");
	 */ 
		List<IpInfo> list = new ArrayList<IpInfo>();
		IpInfo i1 = new IpInfo();
		i1.setIp("213.192.60.99");
		list.add(i1);
		IpInfo i3 = new IpInfo();
		i3.setIp("213.192.60.99");
		list.add(i3);
		IpInfo i4 = new IpInfo();
		i4.setIp("213.192.60.99");
		list.add(i4);
		IpInfo i5 = new IpInfo();
		i5.setIp("213.192.60.99");
		list.add(i5);
		IpInfo i2 = new IpInfo();
		i2.setIp("68.71.76.242");
		list.add(i2);
		list.add(i2);
		IpInfo i6 = new IpInfo();
		i6.setIp("68.71.76.242");
		list.add(i6);
		list.add(i6);
		IpInfo i7 = new IpInfo();
		i7.setIp("68.71.76.242");
		list.add(i7);
		list.add(i5);
		list.add(i5);
		list.add(i7);
		list.add(i3);
		list.add(i2);
		list.add(i4);
		list.add(i7);
		list.add(i4);
		list.add(i7);
		list.add(i5);
		list.add(i7);
		long  time = System.currentTimeMillis();
		List<IpInfo> li = BatchSpeed.getSpeed(list);
		long  time2 = System.currentTimeMillis();
		System.out.println(time2-time);
		System.out.println(Thread.currentThread().getName());
		System.out.println(li.size());
		for(IpInfo ip :li){
			System.out.println(ip.getSpeed()+"--"+ip.getIp());
		}
		
	}
}
